import { Controller } from "egg";

export default class HomeController extends Controller {
  public async index() {
    const { ctx, app } = this;

    // app.io.of("/notify").to(`storeId:538908535845613568`).emit("data", { test: "123123" });

    ctx.body = "SUCCESS";
  }

  async sendMessageToStore() {
    const { ctx } = this;

    const param = ctx.request.body;

    const { bizContent } = param;

    const { storeId, event, params } = JSON.parse(bizContent);

    ctx.service.userSocket.sendMessageToStore(storeId, event, params);

    ctx.body = {
      code: 0,
      msg: "success",
    };
  }
}
